home *** CD-ROM | disk | FTP | other *** search
/ The PC-SIG Library 9 / The PC-SIG Library on CD ROM - Ninth Edition.iso / 301_400 / DISK0339 / DISK0339.ZIP / CSORT.DOC < prev    next >
Text File  |  1983-07-25  |  15KB  |  276 lines

  1.  
  2.  
  3.                    CHEAPSORT (level I AND II) DOCUMENTATION
  4.  
  5.                           CAPABILITIES OF CHEAPSORT
  6.      CHEAPSORT  is a disk-based sort/merge program.  It will sort  data  files 
  7. which  have fixed-length records and fixed-length fields.  The data file being 
  8. sorted may be of any size,  but may not contain more than 32,767 records. This 
  9. should be sufficient for most uses.
  10.      CHEAPSORT  will  not sort sequential data files,  such as  those  written 
  11. using a word processor;  nor will it sort data files written under the UCSD or 
  12. CP/M-86 operating systems, unless the data is somehow transferred to PC DOS.
  13.      CHEAPSORT appears to work correctly under PC DOS 1.1 and 2.0, and on hard 
  14. disk,  floppy disk,  and RAM (or memory) disk. CHEAPSORT is not copy protected 
  15. in  any  way,  and  may  be backed up or transferred freely  to  other  media. 
  16. CHEAPSORT  is copyrighted and trademarked,  and should not be sold  except  as 
  17. noted in this documentation.
  18.      You may sort data of any type commonly used in BASIC. Valid types include 
  19. ASCII data (numbers or letters,  in alphabetic order),  byte,  packed integer, 
  20. packed single precision,  packed double precision,  and any user-defined  data 
  21. type  adhering  to Microsoft's floating point format.  Many other  sorts  have 
  22. difficulty with other than ASCII data types.
  23.      CHEAPSORT is compatible with THE CREATOR,  REPORTOR,  PROGEN, REPGEN, and 
  24. other software sold or distributed by T.N.T. SOFTWARE, INC.
  25.      CHEAPSORT is totally compatible with Microsoft BASIC random-access files. 
  26. Other  sorts  may have some difficulties with  Microsoft  random  files,  even 
  27. appending unwanted control characters to the file output. CHEAPSORT will not.
  28.      You  may sort unpacked numbers in numeric (rather than alphabetic)  order 
  29. by  choosing to sort that field as NUMERIC,  rather than CHARACTER.  CHEAPSORT 
  30. will   convert  any  such  numbers  into  a  packed  double-precision   format 
  31. internally; the sort will be accurate to 16 significant digits.
  32.      CHEAPSORT  will  only output an INDEX to the file in sorted  order.  This 
  33. index will consist of a list of record numbers.  By reading the sorted file in 
  34. the order specified by the index,  you will be reading the file in the  sorted 
  35. order you specified. If you need a whole file output, you may use the index to 
  36. create  one.  See  the end of these notes for a sample program which  you  may 
  37. modify for your use.  The sample program,  incidentally, also shows how to use 
  38. the index to read a data file.
  39.      For  your added convenience,  the sort index file can be read as a random 
  40. file  of  record length 8.  This will allow you to use the index  file  to  do 
  41. binary searches of the data,  if you wish. To help you further, CHEAPSORT will 
  42. always  tell  you exactly how many records were sorted when the sort has  been 
  43. completed. A null record is always appended to the end of the file to help you 
  44. locate  the end,  if you want to do binary searches.  Each record in the  data 
  45. file  to  be sorted can not contain more than 256 characters;  if you  have  a 
  46. requirement which exceeds that,  consider buying CHEAPSORT, level II. The cost 
  47. is $25.00,  postpaid,  from TNT SOFTWARE INC.,  34069 Hainesville Road,  Round 
  48. Lake  IL 60073.  Level II CHEAPSORT will sort input files with lengths  up  to 
  49. 32767 bytes and combined key lengths of up to 32765 bytes (limited by memory).
  50.      If  you  have  more  complex sort  requirements,  or  need  to  customize 
  51. CHEAPSORT (any level), the source code is separately available. Level I source 
  52. code costs an additional $11.00;  level II,  an additional $25.00. Examples of 
  53. customizing  CHEAPSORT to do select/exclude on fields or  field  relationships 
  54. are included with the source code.
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.                                      1
  67.  
  68.  
  69.                              HOW TO RUN CHEAPSORT
  70.      Simple:  while at the DOS prompt (A>,  B>,  etc.) just type in CSORT.  If 
  71. CHEAPSORT  is not on your current default drive,  preface CSORT with the drive 
  72. letter and a colon. For example:
  73. A>B:CSORT
  74. B>A:CSORT
  75.      CHEAPSORT will ask you for the name of the file to be sorted,  the record 
  76. length,  the name of the output index file,  and the beginning position, type, 
  77. and length of each of the sort keys.
  78.      The  beginning  position of each key must  be  carefully  specified.  The 
  79. easiest  way to understand how this should be done is by means of an  example. 
  80. Suppose you want to sort a data file whose record length is 85;  the fields in 
  81. each record are of lengths 15,20,5,20,10,10,  and 5.  Suppose you want to sort 
  82. each record by field 4, then 3, then 6, then 1.
  83.      In  that case,  the starting position of the first key (field 4) would be 
  84. 15+20+5+20=60,  plus  1 (skip the first 60 characters,  start the sort at  the 
  85. 61st character). The key length would be 20, if you want to sort by all of the 
  86. fourth field.  Likewise,  the second key begins at 15+20+1=36,  the third  key 
  87. begins at 15+20+5+20+10+1=71, and the last key begins at position 1.
  88.      You need not use all of a key field as a sort key.  If your key field  is 
  89. very  long (a name field,  with 80 characters allowed,  for example),  you may 
  90. wish to use only the first few characters of the field as the key.  Just enter 
  91. whatever length you decide to use.
  92.      CHEAPSORT will remind you of the permissible data types;  please read the 
  93. possibilities  carefully.  Many of the possible data types (the packed numeric 
  94. ones, especially) are called "Other".
  95.      You  may use up to 50 keys,  but the total length of all of the keys  may 
  96. not exceed 253 bytes. CHEAPSORT will inform you of the remaining key space and 
  97. the number of remaining keys after each key is entered.
  98.      When you are done entering the keys,  you may go on to the next step  (as 
  99. CHEAPSORT  will inform you) by entering the number 0 for the starting position 
  100. for the next key.
  101.      CHEAPSORT will then ask for the drive letter of the drive to use for work 
  102. files.  Many  times,  a  work file will not be  necessary;  if  one  is,  this 
  103. temporary file will be placed on the drive you specify.
  104.      You  may  use any drive for your work files.  If you're sorting a  small-
  105. enough data file (under 1000 records) and you have a small enough  total   key 
  106. length (depends on memory available), you may not actually need any work file. 
  107.      In  any event,  the work file space necessary will not exceed your  total 
  108. key lengths plus two bytes,  times the number of records in the data file. For 
  109. example,  if  your  total of key lengths is 50 bytes and you are sorting  2000 
  110. records,  the space required for your work file will be 52*2000=104000  bytes. 
  111. Be  sure  you have enough space available on the drive you designate for  your 
  112. work files. It is disheartening to run the sort almost to completion and get a 
  113. 'disk full' error message.
  114.      It  is  interesting to note,  in this  connection,  that  CHEAPSORT  uses 
  115. generally  less work file space than other sorts.  You will probably find that 
  116. CHEAPSORT will be capable of sorting data files other sorts cannot touch.
  117.      CHEAPSORT is quite quick,  but is probably not the fastest possible  sort 
  118. for the IBM PC. It is, however, probably the least expensive good sort package 
  119. you will ever buy.  Here are some comparative sort times for the IBM PC, where 
  120. the  sort file and work files were on separate (floppy) disks.  The file being 
  121. sorted consisted of 3000 records, each of 25 bytes in length. There were three 
  122. fields:  a  15-character alphabetic name,  an 8-byte  packed  double-precision 
  123. amount, and a two-byte packed integer field. Print level 4 was used. The times 
  124. quoted  are  from  the last operator entry to CHEAPSORT until the  DOS  prompt 
  125. reappeared.  All data was generated by using BASICs RND function, so no fields 
  126. were in any particular sorted order.
  127.      The  times quoted are from the time of the last operator input until  the 
  128. system prompt returns, and include all disk read and write times.
  129.  
  130.  
  131.  
  132.                                      2
  133.  
  134.  
  135.                SORT TIMES, 3000 RANDOM RECORDS (25 BYTES EACH)
  136.                    ALL TIMES QUOTED ARE MINUTES AND SECONDS
  137. ASCENDING      DESCENDING     KEY(S)
  138. 2:47           2:51           Packed integer.
  139. 3:10           3:56           15 character alphabetic.
  140. 3:20           3:45           Packed double precision.
  141. 3:26                          15 character alphabetic + packed integer.
  142. 3:37                          Packed double precision + packed integer.
  143. 4:04                          15 character alphabetic + packed double prec.
  144. 4:22           5:39           15 char. alpha + packed double + packed int.
  145.  
  146.      Each  run  required  a merge of 3000 records;  this merge  took  about  a 
  147. minute.  If you were to sort fewer than a thousand records, a merge may not be 
  148. required; generally, sort times for such small data files will be well under a 
  149. minute.  The merge function has been highly optimized, and will take advantage 
  150. of  memory buffering as much as possible.  Disk reads of the merge  work  file 
  151. have been reduced to the minimum.
  152.      Sorts in descending order generally take about 2-3% longer than ascending 
  153. sorts for each byte in the descending key field. Merge times are not affected. 
  154. Sorts  of packed single or double precision data take about 10% longer than  a 
  155. sort  on  an  alphabetic key of the same size.  Again,  merge  times  are  not 
  156. affected. Merges will take somewhat longer if the key lengths are longer.
  157.      CHEAPSORT  will  run  more slowly if the disk data is  in  reverse  order 
  158. compared  to  the sort order requested.  I have done no checking on times  for 
  159. this,  but it should be possible to double the sort times if the data were  in 
  160. exactly reverse order.  On the other hand, if the data were in close to sorted 
  161. order  to  begin with,  CHEAPSORT could run appreciably faster than  indicated 
  162. here. Sort times in that instance would probably be primarily limited by disk 
  163. transfer times.
  164.      On  some machines,  it is possible to appreciably speed up  CHEAPSORT  by 
  165. specifying print level 1.  On the IBM PC, it makes a difference of only two or 
  166. three  seconds on the above sort.  Therefore,  there is no real penalty if you 
  167. like to watch how the sort is progressing.
  168.      You  may find it hard to believe (especially considering the  speed  with 
  169. which  CHEAPSORT  operates),  but CHEAPSORT was written entirely in  Microsoft 
  170. BASIC.   This  was  done  quite  deliberately,  so  that  CHEAPSORT  would  be 
  171. transportable to as many new machines as possible,  and would be adaptable  to 
  172. any  new operating system releases from either Microsoft or IBM.  If there  is 
  173. sufficient demand,  I may produce a version of CHEAPSORT for CP/M-86. However, 
  174. I consider this rather unlikely; most CP/M-86 software tends to get written in 
  175. and for the Digital Research languages, for which I have no love whatsoever. 
  176.      System  builders and developers might want to incorporate CHEAPSORT  into 
  177. their software; or, a user may obtain a copy of either version of CHEAPSORT in 
  178. order to 'test' its capabilities.  In any case,  if you wish to sell CHEAPSORT 
  179. or  'buy' a copy in order to make your sale or possession legal,  you need  do 
  180. the following:
  181.      (1) Remit $5 for CHEAPSORT level I, or $10 for CHEAPSORT level II;
  182.      (2)  Send the name and full address of the ultimate user of the  software 
  183. to T.N.T. SOFTWARE, INC. at 34069 Hainesville Road, Round Lake IL 60073.
  184.      Others  using  or  selling CHEAPSORT do so  without  any  possibility  of 
  185. support and with the possibility of legal action against them for such illegal 
  186. use or sale.
  187.      T.N.T.  SOFTWARE  has a very easy distribution policy,  and very low cost 
  188. software. It is our belief that software prices are entirely too high; but, if 
  189. our software is pirated and we obtain little gain from our policies,  we  will 
  190. have  only  two choices:  increase prices or leave the  market.  Neither  will 
  191. result  in any long-term advantage to the software buyer.  Please help us keep 
  192. prices low, and obey our requests for sale and distribution of our software.
  193.  
  194.  
  195.  
  196.  
  197.  
  198.                                      3
  199.  
  200.  
  201.                SAMPLE PROGRAM TO READ A DATA FILE VIA AN INDEX
  202.                         AND CREATE A WHOLE FILE OUTPUT
  203.  
  204. 10 LINE INPUT"FILE TO READ:";F$
  205. 20 LINE INPUT"FILE TO WRITE:";W$
  206. 30 LINE INPUT"INDEX FILE NAME:";I$
  207. 40 INPUT"RECORD LENGTH:";R:'IF RECORD LENGTH >255 YOU WILL NEED TO ALTER
  208. 50 OPEN"R",1,F$,R:'      LINES 60 AND 80 FOR A MORE COMPLICATED
  209. 60 FIELD #1,R AS A$:'    FIELD STATEMENT. USE AS MANY VARIABLES AS NEEDED
  210. 70 OPEN"R",2,W$,R:'      TO USE UP ALL THE CHARACTERS IN EACH RECORD.
  211. 80 FIELD #2,R AS B$:'    FOR EXAMPLE:
  212. 90 OPEN"I",3,I$:'        FIELD #1, 255 AS A1$,255 AS A2$,255 AS A3$
  213. 91 '                     WILL HANDLE A RECORD OF 765 BYTES. YOU WILL
  214. 92 '                     NEED TO FIELD #2 SIMILARLY, AND DO THE LSETS IN LINE
  215. 93 '                     110 AS WELL. THE LSETS CAN BE DONE LIKE THIS:
  216. 94 '                     LSET B1$=A1$:LSET B2$=A2$:LSET B3$=A3$
  217. 95 '                     FURTHER NOTE: IF YOUR RECORD LENGTH EXCEEDS 128, YOU
  218. 96 '                     SHOULD BE SURE TO ENTER BASIC WITH THE /S: SWITCH
  219. 97 '                     SET APPROPRIATELY. SEE YOUR BASIC MANUAL.
  220. 100 PRINT"TRANSFERRING":ON ERROR GOTO 500
  221. 110 INPUT #3,A:GET 1,A:LSET B$=A$:COUNT=COUNT+1:PUT 2,COUNT
  222. 120 GOTO 110
  223. 500 PRINT"DONE.";COUNT;"RECORDS TRANSFERRED."
  224. 510 CLOSE:END
  225.  
  226.  
  227. THANKS FOR PURCHASING CHEAPSORT!
  228. FOR A CATALOG OF OUR OTHER INEXPENSIVE,  HIGH-QUALITY SOFTWARE FOR THE IBM PC, 
  229. CP/M, AND RADIO SHACK MACHINES, WRITE TO:
  230.  
  231.                             T.N.T. SOFTWARE, INC.
  232.                             34069 HAINESVILLE ROAD
  233.                              ROUND LAKE, IL 60073
  234.                                 (312) 223-0832
  235.  
  236.  
  237. IBM PC is a registered trademark of The IBM Corporation;  CP/M and CP/M-86 are 
  238. trademarks  of  Digital  Research;   Radio  Shack  is  a  trademark  of  Tandy 
  239. Corporation;   THE  CREATOR,  REPORTOR,  PROGEN,  REPGEN,  and  CHEAPSORT  are 
  240. trademarks of T.N.T. SOFTWARE, INC.
  241.  
  242.  
  243.  
  244.  
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.  
  262.  
  263.  
  264.                                      4
  265.  
  266.  
  267.  
  268.         This disk copy was originally provided by "The Public Library",
  269.         the software library of the Houston Area League of PC Users.
  270.  
  271.         Programs are available from the Public Library at $2 per disk
  272.         on user-provided disks.  To get a listing of the disks in the
  273.         Public Library, send a self-addressed, stamped envelope to
  274.  
  275.              Nelson Ford,  P.O.Box 61565,  Houston, TX 77208.
  276.